/**
 * 鼻涕 节点
 */
cc.Class({
    extends: cc.Component,

    properties: {
        //鼻涕转动角度
        rotateDegree: 20,

        //鼻涕转动一次需要时间(不是一个来回，是单程用时)
        rotateTime: 0.25,

        //点击一次，鼻涕抖动次数
        boogerShakingTimes: 2
    },

    setRotateAction() {
        //顺时针旋转
        let clockwiseRotation = cc.rotateBy(this.rotateTime, this.rotateDegree).easing(cc.easeCubicActionOut());

        //向左转
        let AnticlockwiseRotation = cc.rotateBy(this.rotateTime, -this.rotateDegree).easing(cc.easeCubicActionOut());;

        return cc.repeat(cc.sequence(AnticlockwiseRotation, clockwiseRotation), this.boogerShakingTimes);
    },

    // LIFE-CYCLE CALLBACKS:
    onLoad() {
        //将当前this对象保存一份，因为在回调函数中this将不会指向当前的this
        const _self = this;

        //初始化鼻涕抖动动作对象
        this.rotateAction = this.setRotateAction();

        //在该节点加载完成后给该节点绑定点击事件
        this.node.on(cc.Node.EventType.TOUCH_END, function (ev) {
            _self.node.runAction(_self.rotateAction);
        })
    },

    onDestroy() {},

    start() {},

    // update (dt) {},
});